<h1>Listado de Culturas</h1>
<br/>

<% form_tag url_for(:action=>"map_search") do -%>
  <div id = "cultures_table">
    <% if @cultural_heritage_cultures.size > 0 %>
      <table class="paginated_table">
        <thead>
          <tr>
            <th>Nombre</th>
            <th>Descripción</th>
            <th>Elegir</th>
          </tr>
        </thead>
        <tbody>
          <% @cultural_heritage_cultures.each do |cultural_heritage_culture| %>
            <tr>
              <td>
                <%= link_to cultural_heritage_culture.name,{:controller=>"/cultural_heritage/cultures",:action => 'show',:id => cultural_heritage_culture.id},:title => cultural_heritage_culture.description %>
              </td>
              <td><%= cultural_heritage_culture.description %></td>
              <td><input type="checkbox" name="lculture[]" value="<%=cultural_heritage_culture.id%>" id="<%=cultural_heritage_culture.id%>"/></td>
            </tr>
          <% end %>
        </tbody>
      </table>
      <input type="submit" value="Mostrar en mapa">
    <% else %>
      <p> Ninguna cultura encontrada</p>
    <% end %>
  </div>

  <% if !(@json.nil? || @json.blank? || @json == "") %>
    <!-- Aquí va gmaps -->
    <%= stylesheet_link_tag 'gmaps4rails' %>
    <div  style="width: 880px; height: 455px">
      <fieldset id="agrupacion" style="width:620px; float: left">
        <legend>Ubicación</legend>
        <%= gmaps({
            "map_options" => { "type" => "HYBRID", "center_longitude" => 180, "zoom" => 7, "auto_adjust" => true},
            "polygons"    => { "data" => @json }
          })
      %>
      </fieldset>
      <fieldset  id="agrupacion" style="width:210px; float: right ; height:442px; overflow-y:auto;">
        <legend>Georeferencia</legend>
        <ul style="list-style-type: none">
          <% @arr.each do |elem| %>
            <li><span style="background-color: <%= elem[1] %>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <%= elem[0] %></li>
          <% end %>
        </ul>
      </fieldset>
    </div>

  <% end %>
<% end %>
<div id="lineaform"></div>
<% if (user_signed_in? && ([2].include?(current_user.role))) %>
  <p><%= link_to 'Nueva Cultura', new_cultural_heritage_culture_path %></p>
<%end%>
<fieldset class="column-right4">
  <%= link_to 'Búsqueda de Culturas',{:controller => '/cultural_heritage/cultures', :action => 'index'}%>
</fieldset>
